package com.thinvent.recommend.service.impl;

import com.thinvent.recommend.manager.dto.DocVectorDTO;
import com.thinvent.recommend.manager.manager.ESQueryManager;
import com.thinvent.recommend.service.ESQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

/**
 * Elasticsearch 向量查询服务实现
 */
@Service
public class ESQueryServiceImpl implements ESQueryService {

    private final ESQueryManager esQueryManager;

    @Autowired
    public ESQueryServiceImpl(ESQueryManager esQueryManager) {
        this.esQueryManager = esQueryManager;
    }

    @Override
    public List<DocVectorDTO> searchAll(int page, int size) throws IOException {
        return esQueryManager.searchAll(page, size);
    }

    @Override
    public List<DocVectorDTO> searchByDate(String startDate, String endDate, int page, int size) throws IOException {
        return esQueryManager.searchByDate(startDate, endDate, page, size);
    }

    @Override
    public DocVectorDTO getById(String docId) throws IOException {
        return esQueryManager.getById(docId);
    }

    @Override
    public void deleteByIds(List<String> docIds) throws IOException {
        esQueryManager.deleteByIds(docIds);
    }

    @Override
    public void clearAll() throws IOException {
        esQueryManager.clearAll();
    }

    @Override
    public void deleteIndex() throws IOException {
        esQueryManager.deleteIndex();
    }

    @Override
    public String getIndexMapping() throws IOException {
        return esQueryManager.getIndexMapping();
    }
}
